\subsection{Object-detection}
Detects objects in an images. To detect objects in images we go
through different states. First we convert the image to grey scale,
then we use a threshold function on the grey scale image. Last we use
Suzuki's algorithm\cite{suzuki1985topological} which finds the contours
and return them as Freeman's chain code\cite{freeman1974computer}
to detect shapes in the image.

\subsubsection{Threshold function}
We use a threshold function that set each pixel to zero if they are
smaller then the threshold otherwise the pixel get the maximum value.
\begin{equation}
dst(x,y)= \left\{ 
\begin{array}{l l}
maxValue & \quad if src(x,y)>T(x,y)\\
0 & \quad otherwise
\end{array} 
\right.
\end{equation}

\subsubsection{Suzuki's algorithm}
Suzuki's algorithm finds contours in images by taking am image where
the pixels have the value 0 or 1. It goes through the image pixel for
pixel starting in the upper left corner and look for a pixel that have
a neighbour on the same row that don't have the same value. Depending
on the values the algorithm labels the pixel. The algorithm finds
both outer contours and holes. The output is a contour that is in
the Freeman's chain code format.

\begin{comment}
Suzuki's algorithm is a search algorithm that finds borders in the image.
The algorihm take a raster image, let the input image be \(F=\{f_{ij}\}\). We have a counter that Suzuki call NBD that is counting the borders, in the start NBD is 1. For each new row we start to scan of the image we reset the LNBD counter to 1.

Now the algorithm scaning through the image and for each pixel that is \(f_{ij}\neq0\) we perform the following steps. 
\begin{enumerate}
\item Select on of the following step:
	\begin{enumerate}
	\item If \(f_{ij}=1\) and \(f_{i,j-1}=0\) then the pixel \((i,j)\) is a border and a starting point of an outer border, increment NBD, and set \((i_2,j_2)\) to \((i,j-1)\).
	\item Else if \(f_{ij} \geq 1\) and \(f_{i,j+1}=0\) then the pixel \((i,j)\) is a border and a staring pint of a hole border, increment NBD, set \((i_2,j_2)\) to \((i,j+1)\), and if \(f_{ij}>1\) set LNBD to \(f_{ij}\).
	\item Else, go to pint 4.
	\end{enumerate}
\item \emph{Mer att skriva, om det \"ar n\"odv\"adigt att ha algoritmen med} 
\end{enumerate}
\end{comment}

\subsubsection{Freeman's chain code}
Freeman's chain code is a way to describe borders/contours. You have
a staring point and then you say which neighbour is next and that in
turn say who's next. To describe who's next he use a system shown in
figure \ref{fig:freeman}, so to describe a square that is \(2\times2\)
the Freeman chain code looks like this, if we start in the upper left
corner: 00664422.

\begin{figure}[ht!]
\begin{displaymath}
\xymatrix@C=30pt@R=20pt@L=0pt{
3 & 2 & 1 \\
4 & \bullet 
\ar@{->}[ul]  \ar@{->}[u] \ar@{->}[ur] 
\ar@{->}[l] \ar@{->}[r] 
\ar@{->}[dl] \ar@{->}[d] \ar@{->}[dr]
& 0 \\
5 & 6 & 7 
}
\end{displaymath}
\caption{\label{fig:freeman} The Freeman chain-encoder}
\end{figure}


